<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="Cache-control" content="no-cache">
<meta http-equiv="Cache" content="no-cache">
<meta http-equiv="Cache-Control" content="no-siteapp" />
<link rel="shortcut icon" href="/favicon.ico">
<meta name="viewport"
	content="initial-scale = 1.0, maximum-scale = 1.0, user-scalable = no, width = device-width">
<link rel="stylesheet" href="/common/css/monitor/index_server.css" type="text/css"/>
    <link rel="shortcut icon" href="/favicon.ico"> <link href="/css/bootstrap.min.css?v=3.3.5" rel="stylesheet">
    <link href="/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
    <link href="/css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
    <link href="/css/animate.min.css" rel="stylesheet">
    <link href="/css/style.min.css?v=4.0.0" rel="stylesheet">
</head>
<style type="text/css">
	#warningShowTabel{
	margin:40px auto;
		font-size: 14px;
		width: 100%;
	}
	.warningTr{
		width: 100%;
		line-height: 24px;
		text-align: center
	}
	.warningTr td,span{
		border: 0px;
	}
	.warningTr span{
		color: black;
	}
	.checkSpan{
		padding-left: 15px;
	}
	.warningTr label:hover{
		cursor: pointer;
		text-decoration: underline;
	}
	.warningTr label{
		color:#158144;
		width: 140px;
		overflow: hidden;
		white-space: nowrap;
		text-overflow: ellipsis;
		font-style: normal;
		margin: -7px;
	}
	.warningTr input{
		zoom:120%;
	}
	.mar_tow{
		margin-left: 15px;
		text-align: center;
	}
	.warningEmplInfo{
		padding-left: 15px;
	}
</style>
<body>
	<div style="width: 100%;">
		<table id="warningShowTabel" cellspacing="0">
		</table>
		<div style="height: 50px;"></div>
		<div style="width: 100%;height: 43px;position: fixed;bottom: 0px;left:0px;background-color: #fff; text-align: center;">
				<button id="allSelect" type="button" class="btn btn-white mar_tow">全选</button>
				<button id="returnSelect" type="button" class="btn btn-white mar_tow">反选</button>
				<button id="okRead" type="button" class="btn btn-success mar_tow">全部已读</button>
				<button id="selectRead" type="button"class="btn btn-success mar_tow">选中已读</button>
		</div>
	</div>
	<script src="/js/jquery.min.js?v=2.1.4"></script>
	<script src="/js/bootstrap.min.js?v=3.3.5"></script>
	<script src="/js/content.min.js?v=1.0.0"></script>
	<script src="/common/petecat.js"></script>
	<script src="/common/form.js"></script>
	<!-- HTML之间的传值 -->
	<script src="/js/jquery.params.js"></script>
	<script src="/js/plugins/layer-pc/layer.js"></script>
	<script src="/js/jquery.cookie.js"></script>
    <!-- 组件通用 -->
    <script src="/common/frame.js"></script>
    <script type="text/javascript">
    	var ruleId = GetQueryString("ruleId")
	   $(function(){
		   //初始化预警信息
		   initWarningNotice(ruleId)
		   $("#warningShowTabel").on("click",".warningEmplInfo",function(){
			   var esId = $(this).attr("esId");
			   layer.open({
	                type: 2,
	                title: "预警人员信息",
	                shade: 0.8,
	                area: ['100%', '100%'],
	                content: ['/monitor/warning_empl_info.html?esId='+esId, 'auto']
	            });
		   });
		   
	   });
    
	function initWarningNotice(ruleId){
		var req = {};
       	req['reqJSON'] = {
       			type : 'get',
       			url : BASE_URL+'/base/warningconfig/getWarningByRuleId?ruleId='+ruleId
           };
       	req['successFn'] = function(respData){
       		var html = "";
       		var number = 0;
       		if(respData.code == SUCCESS_CODE){
       			if(respData.data.length > 0){
       				$.each(respData.data,function(index,item){
           				number = index+1;
               			html += '<tr class="warningTr">'+
    	                			'<td><span>'+number+'、</span><label for="notice'+number+'">'+item.remark+'</label>&nbsp; &nbsp; &nbsp;'+item.sendTime+'<span class="checkSpan"><input id="notice'+number+'" type="checkbox" value='+item.id+'></span><a class="warningEmplInfo" esId="'+item.id+'">详情</a></td>'+
    	                		'</tr>';
           			});
                  $("#warningShowTabel").html(html);
       			}else{
       			  $("#warningShowTabel").html("<h2 style='color:#1ab394;'>恭喜，当前没有预警通知消息！</h2>");	
       			}
       		}else{
       			//查询错误
       		}
       	};
       	ajaxRequest(req);
	 }
	//全部已读
	 $("#okRead").click(function(){
		 $("#allSelect").click();
			submitReadStatus();
	 });
	//选中已读
	$("#selectRead").click(function(){
		submitReadStatus();
	});
	
	function submitReadStatus(){
			var ids = new Array();
			$("input[type=checkbox]:checkbox:checked").each(function(){
				 //由于复选框一般选中的是多个,所以可以循环输出
				 ids.push($(this).val());
			}); 
			if(ids.length <= 0){
				layer.alert("请选择已读的预警通知！",{icon:2});
				return;
			}
			var req = {};
	       	req['reqJSON'] = {
	       			type : 'get',
	       			url : BASE_URL+'/base/warningconfig/updateEsWarningReadStatusById?ids='+ids
	        };
	       	req['successFn'] = function(respData){
	       		var index = parent.layer.getFrameIndex(window.name); //获取当前窗体索引
	       	 	parent.layer.close(index); //执行关闭
	       	};
	       	ajaxRequest(req);
	}
	
	//全选
	$("#allSelect").click(function(){
		$("input[type='checkbox']").prop("checked",true);
	});
	//反选
	$("#returnSelect").click(function(){
		$("input[type='checkbox']").each(function(){
				if($(this).prop("checked")){ 
					$(this).removeAttr("checked"); 
				} 
				else{ 
					$(this).prop("checked","true"); 
				} 
		})
	});
	
	
	</script>
    
</body>
</html>